<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <!-- 无障碍访问 -->
    <label for="keywords">keywords</label>
    <input type="text" id="keywords"><!--autofocus 自动聚焦--> 
    <script>
        const input=document.querySelector('#keywords');
       /* input.addEventListener('focus',function(event){
            console.log('focus  表单聚焦事件');
        })*/
        // 及时收集值
        input.addEventListener('input',function(){//keyup keydown input
       console.log(this.value);
        });
        // enter 健 keydown 
        //input.focus();
        input.addEventListener('keydown',function(event){//keyup keydown input
       console.log(event.keyCode);
       if(event.keyCode==13){
           console.log('提交表单')
       }
    })
    </script>
</body>
</html>